define(function(require,exports,module){

	
	
	//表单验证
	require.async("/plugins/jquery-validation-1.13.0/jquery.validate",function(){
		$("#addBankForm").validate({
			rules:{
				branch:{
					required:true
				},
				bankNo:{
					required:true,
					rangelength:[15,19]
				},
				comfirmAccount:{
					required:true,
					equalTo:"#infoyhzh"
				}
			},
			messages:{
				branch:{
					required:"请输入开户银行名称",
				},
				bankNo:{
					required:"请输入银行账号",
					rangelength:"请输入{0}~{1}位银行账号"
				},
				comfirmAccount:{
					required:"确认银行账号",
					equalTo:"两次输入的银行卡不一致，请重新输入"
				}
			},
			errorElement:"em",
			errorPlacement:function(error,element){
				error.appendTo(element.parent().find("span"));
			},
			submitHandler:function(form,event,validator){
				 require.async('jquery.form',function(){
					 $(form).ajaxSubmit({
    					dataType:'json',
    					success:function(data){
    						require.async(['/plugins/layer-v1.8.4/skin/layer.css','/plugins/layer-v1.8.4/layer.min'],function(){
	    						if(data.result){
	    							$.layer({
	    							    type: 1,
	    							    closeBtn: [0,true],
	    				                		    title: "&nbsp;",
	    							    area: ['384px', '186px'],
	    							    border: [1, 1, '#cecfd0'],
	    							    time:3,
	    							    page: {
	    							        html: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>添加银行卡成功</span></div><div class="tipsMsg">3秒后窗口自动关闭</div></div>'
	    							    },
	    							    close: function(index){
	    							    	window.location.href = "/member/cash/bank.html";
	    							    },
	    							    end: function(){
	    							    	window.location.href = "/member/cash/bank.html";
	    							    },
	    							    success: function(layero){
	    							    	var time =3; 
	    							    	function closeTime () {
	    										time--;
	    										$(".tipsMsg").html(time+"秒后窗口自动关闭");
		    								}
	    							    	setInterval(function(){
    											closeTime();
    										}, 1000);
	    							    }
	    							});
		    					}else{
		    						$.layer({
									    type: 1,
									    closeBtn: [0,true],
						                		    title: "&nbsp;",
									    area: ['384px', '186px'],
									    border: [1, 1, '#cecfd0'],
									    page: {
									        html: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+data.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn failBtn">确定</a></div></div>'
									    },
									    close: function(index){
									    	layer.closeAll();
									    }
									});
		    						$(".failBtn").click(function(){
		    							layer.closeAll();
									});
		    					}
	    					})
    					}
    				});
				 })
			}
		});
	})
	
	//加载城市选择插件
	require.async('jquery-citySelect/jquery.cityselect',function(){
		$("#city").citySelect({
		    url:"../../../themes/theme_default/media/js/jquery-citySelect/city.json",
	 	    prov:"浙江", //省份 
		    city:"杭州", //城市 
		    dist:"西湖区", //区县 
		    required:true,
		    nodata:"none" //当子集无数据时，隐藏select 
		});
	})
});